package com.xxlie.auth.domain;

import com.xxlie.auth.domain.base.BaseEntity;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 * 系统设置
 */
@Entity
@Table(name = "sys_setting")
public class Setting extends BaseEntity {
    public final static int TYPE_SYSTEM = 0;
    public final static int TYPE_CUSTOMER = 1;

    private Long id;            //自增主键ID
    private String title;       //标题描述
    private String name;        //键名
    private String value;       //键值
    private int type;           //类型，1=系统设置，0=用户设置
    private int fieldType;     //字段类型,0=整型，1=字符串

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @NotNull(message = "标题描述不能为空")
    @Length(min = 1, max = 255, message = "标题描述长度必须介于1到32之间")
    @Column(name = "title", length = 255)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @NotNull(message = "键名不能为空")
    @Length(min = 1, max = 32, message = "键名长度必须介于1到32之间")
    @Column(name = "name", length = 32)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "value", columnDefinition = "text")
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Column(name = "type", length = 2, columnDefinition = "INT default 0")
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Column(name = "field_type", columnDefinition = "INT default 0")
    public int getFieldType() {
        return fieldType;
    }

    public void setFieldType(int fieldType) {
        this.fieldType = fieldType;
    }
}
